package com.yss.datamiddle.config;

import com.yss.datamiddle.Interceptor.AuthInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.*;

@Configuration
public class WebConfig extends WebMvcConfigurationSupport {


	@Bean
	AuthInterceptor localInterceptor() {
		return new AuthInterceptor();
	}

	@Override
	public void addInterceptors(InterceptorRegistry registry) {
		registry.addInterceptor(localInterceptor())
				.addPathPatterns("/**")
				// 静态资源
				.excludePathPatterns("/js/**", "/css/**", "/images/**", "/lib/**",
						"/fonts/**","/doc.html/**")
				// swagger-ui
				.excludePathPatterns("/swagger-resources/**", "/webjars/**",
						"/v2/api-docs/**", "/swagger-ui.html/**");
	}

	@Override
	protected void addResourceHandlers(ResourceHandlerRegistry registry) {
		registry.addResourceHandler("doc.html")
				.addResourceLocations("classpath:/META-INF/resources/");
		registry.addResourceHandler("/webjars/**")
				.addResourceLocations("classpath:/META-INF/resources/webjars/");
	}

}